
import { useState, useEffect } from 'react';
import { RoleRequest, RoleStruct } from 'spd-request/role';
import { message, Select } from 'antd';
function  useRoleOptions() {
    let [roles, setRoles] =  useState<RoleStruct[]>([]);
    useEffect(() => {
        RoleRequest.getRoles({pageSize: 1000}).then(({error, data}) => {
            if(error === null) {
                setRoles(data.items);
            } else {
                message.error(error)
            }
        });
    }, []);
    return (
        roles.map(item => {
            return <Select.Option value={item.id} key={item.id}>{item.displayName}</Select.Option>
        })
    );
}
export function RoleSelectTree() {
    let options = useRoleOptions();
    return (
        <Select placeholder="请选择角色">
            {options}
        </Select>
    );

}